import java.util.Hashtable;
//import EA.*;
import EA.BatchJobEA;
import batchjob.*;
public class TumorModel implements BatchJobEA {

    /* Toggle debug output to console */
    private static final boolean DEBUG = false;
    TwoDimSim tds;
    
    public TumorModel() {
	super();
    }
        
    // **** BatchJob implementation *****************************
    
    /** Set the settings for the algorithm. The passed hashtable contains
	only String objects which are all related to the input file given 
	to the scheduler. 
    */
    public void setSettings(Hashtable settings) {
	tds = new TwoDimSim();
	((BatchJobEA)tds).setSettings(settings);
    }
    
    /** Get the default settings in the BatchJobScheduler format. This 
	method can be used to reconstruct an input file for the scheduler. 
    */
    public String getDefaultSettings() {
	TwoDimSim tds = new TwoDimSim();
	StringBuffer res = new StringBuffer();
	res.append(BatchJobScheduler.getDefaultSettings());
	res.append("#################################################################\n");
	res.append("# ------------- Algorithmic settings ----------------------------\n");
	res.append("\n");
	res.append("# Print information to stdout (true/false)\n");
  	res.append("verbose = "+tds.verbose+"\n\n");
	
	res.append("# Maximal number of steps\n");
 	res.append("maxsteps = "+tds.maxsteps+"\n\n");

	res.append("# Benefit\n");
  	res.append("benefit = "+tds.benefit+"\n\n");

	res.append("# Cost\n");
  	res.append("cost = "+tds.cost+"\n\n");

	res.append("# Population size\n");
  	res.append("populationsize = "+tds.populationsize+"\n\n");

	res.append("# Mortality\n");
  	res.append("mortality = "+tds.mortality+"\n\n");

	res.append("# Initial freq of cancer cells\n");
  	res.append("initfreq = "+tds.initfreq+"\n\n");
  		
	res.append("# Payoff method.\n");
	res.append("# 0 = Repeated Two-player game.\n");
	res.append("# 1 = n-player game.\n");
	res.append("updatemethod = 0\n\n");
	
	res.append("# Neighborhood.\n");
	res.append("# 0 = Moore.\n");
	res.append("# 1 = Von Neumann.\n");
	res.append("neighborhood = 0\n\n");

	res.append("# Display GUI (gridspace).\n");
	res.append("# 0 = Don't display gui.\n");
	res.append("# 1 = Display gui.\n");
	res.append("displaygrid = 1\n\n");
	return res.toString();
    }
    
    /** Initialize a batchjob. This is called once before any run is performed.
     */
    public void initializeBatchJobs() {}
    
    /** Finalize a batchjob. This is called once after all runs are performed.
     */
    public void finalizeBatchJobs() {
	((BatchJobEA)tds).finalizeBatchJobs();
    }
    
    /** Initialize a run series. This is called once before the specified 
	number of runs are performed. (BJSruns in the batchfile)
    */
    public void initializeRunSeries() {
	((BatchJobEA)tds).initializeRunSeries();
    }
    
    /** Finalize a run series. This is called once after the specified 
	number of runs are performed. (BJSruns in the batchfile)
    */
    public void finalizeRunSeries() {
	((BatchJobEA)tds).finalizeRunSeries();
    }
    
    /** Initialize and start a single run of the algorithm. You can 
	usually just call doEA() from your framework.
    */
    public void initializeAndStartRun() {
	((BatchJobEA)tds).initializeAndStartRun();
    }
    
    /** Finalize the single run of the algorithm. This is called immediately
	after the initializeAndStartRun(). It can be used to reset 
	measurements, increase counters, etc.
    */
    public void finalizeRun() {
	((BatchJobEA)tds).finalizeRun();
    }
    
    /** Get the run data as text. Your implementation must return
	an array of objects that each implements the interface ConvertToText from the package
	EA.recording. You can use the classes found in EA.recording or 
	implement your own classes.
	@see EA.recording.ConvertToText
    */
    public Object[] getDataAsText() {
	return ((BatchJobEA)tds).getDataAsText();
    }

}



    
    


























































